import { Redirect, Route, useLocation } from 'react-router-dom'
import { hasToken } from '@/utils/token'
export default function PrivaeRoute({ children, ...props }) {
    // console.log({ children, ...props });
    const location = useLocation()
    // console.log();
    return <Route {...props} render={() => {
        if (hasToken()) {
            return children
        } else {
            return <Redirect to={{ pathname: '/login', state: { from: location.pathname } }}></Redirect>
        }
    }}></Route>
}